Skip to content

Add StabilizerTable class#3931

Merged
mergify[bot] merged 13 commits into
Qiskit:masterfrom
chriseclectic:symplectic/stabilizer-table
Mar 26, 2020
Merged

Add StabilizerTable class#3931
mergify[bot] merged 13 commits into
Qiskit:masterfrom
chriseclectic:symplectic/stabilizer-table

Conversation

@chriseclectic
Copy link
Copy Markdown
Member

@chriseclectic chriseclectic commented Mar 4, 2020

Summary

Adds a StabilizerTable subclass of PauliTable that is an efficient representation of a list of N-qubit stabilizers (real Pauli matrices with +1 or -1 coefficients). This class is implemented by adding a boolean phase vector the Pauli table symplectic array.

This class will be used as a basis for a Clifford operator class.

Details and comments

@chriseclectic chriseclectic added this to the 0.13 milestone Mar 4, 2020
@chriseclectic chriseclectic force-pushed the symplectic/stabilizer-table branch 2 times, most recently from b2edf7b to 4897fb9 Compare March 6, 2020 17:47
@chriseclectic chriseclectic mentioned this pull request Mar 6, 2020
10 tasks
@chriseclectic chriseclectic force-pushed the symplectic/stabilizer-table branch 2 times, most recently from 3c986a6 to 9832b02 Compare March 12, 2020 19:38
@chriseclectic chriseclectic added Changelog: Added Add an "Added" entry in the GitHub Release changelog. on hold Can not fix yet labels Mar 12, 2020
@chriseclectic chriseclectic force-pushed the symplectic/stabilizer-table branch from 9832b02 to 0c39df0 Compare March 20, 2020 18:10
@chriseclectic chriseclectic removed the on hold Can not fix yet label Mar 20, 2020


class StabilizerTable(PauliTable):
r"""Symplectic representation of a list Stabilizer matrices.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

\end{array}\right)

where each row is a block vector :math:`[X_i, Z_i]` with
:math:`X = [x_{i,0}, ..., x_{i,N-1}]`, :math:`Z = [z_{i,0}, ..., z_{i,N-1}]`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"x_i = [x_{i,0},...]"?

"""

def __init__(self, data, phase=None):
"""Initialize the PauliTable.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StabilizerTable


def __getitem__(self, key):
"""Return a view of StabilizerTable"""
if isinstance(key, (int, np.int)):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance(np.int(2), int) returns True so not sure these need to be distinguished.

Pauli rows (Default: False).

Returns:
PauliTable: the resulting table with the entries inserted.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StabilizerTable

sort_inds = index.argsort()
index = index[sort_inds]
unique = self[index]
# Concatinate return tuples
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

if not isinstance(other, StabilizerTable):
other = StabilizerTable(other)
if qargs is None and other.num_qubits != self.num_qubits:
raise QiskitError("other PauliTable must be on the same number of qubits.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to reference StabilizerTable here?

r"""Convert to a list or array of Stabilizer matrices.

For large StabilizerTables converting using the ``array=True``
kwarg will be more efficient since it allocates memory a full
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..for a...

Comment on lines +109 to +112
with self.subTest(msg='str init "I"'):
value = StabilizerTable('I')._array
target = np.array([[False, False]], dtype=np.bool)
self.assertTrue(np.all(np.array(value == target)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is already covered above.

@mergify mergify Bot merged commit 06ba774 into Qiskit:master Mar 26, 2020
@chriseclectic chriseclectic deleted the symplectic/stabilizer-table branch April 15, 2020 14:50
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* Add StabilizerTable class

* Symplectic representation of a list of N-qubit Pauli's with +1 or -1 phases

* Add stabilizer table tests

* Add release note

* Fix _add and _multiply methods

* Linting

* Update qubit ordering and tests

* Doc warning fix

* Rename n_qubits to num_qubits

* Add qargs add to StabilizerTable

* Fix links in release note

* Update for review comments

Co-authored-by: ewinston <ewinston@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Added Add an "Added" entry in the GitHub Release changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants